/**
 * Project Name:mauto-web
 * File Name:ApiJsDicController.java
 * Package Name:com.inftech.mauto.jy.web.jsPad
 * Date:2017年6月16日下午3:01:48
 * Copyright (c) 2017, inf-technology Co., Ltd. All Rights Reserved.
 *
*/

package com.inftech.mauto.jy.web.jsPad;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.inftech.mauto.common.base.BaseController;
import com.inftech.mauto.common.base.BusinessException;
import com.inftech.mauto.common.constant.HttpStatusCodeEnum;
import com.inftech.mauto.jy.entity.MtDic;
import com.inftech.mauto.jy.service.MtDicService;
import com.inftech.mauto.jy.web.CompanyAction;

/**
 * ClassName:ApiJsDicController <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Date: 2017年6月16日 下午3:01:48 <br/>
 * 
 * @author Administrator
 * @version
 * @since JDK 1.7
 */
@Controller
@RequestMapping(value = "/api/js/dict",produces="application/json;charset=utf-8")
public class ApiJsDicController extends BaseController {
	
	Log log = LogFactory.getLog(CompanyAction.class);
	
	/**
	 * 字典Service
	 */
	@Resource(name = "mtDicServiceImpl")
	private MtDicService mtDicServiceImpl;

	/**
	 * 
	 * list:(获取数据字典). <br/>
	 *
	 * @author Administrator
	 * @param request
	 * @param response
	 * @param type
	 * @return
	 * @since JDK 1.7
	 */
	@RequestMapping(value = { "list" })
	@ResponseBody
	public String list(HttpServletRequest request, HttpServletResponse response) {
		String outJson = null;
		try{
			String type = request.getParameter("type");
			List<MtDic> mtDicList= mtDicServiceImpl.getMtDicByParentKey(type);
			HttpStatusCodeEnum statusCode = HttpStatusCodeEnum.STATUS_CODE_200;
			outJson = getOutJson1(statusCode, false, statusCode.toString(), mtDicList);
			log.info("获取字典信息成功！");
		}catch(Exception e){
			if (e instanceof BusinessException) {
				throw e;
			}
			HttpStatusCodeEnum statusCode = HttpStatusCodeEnum.SCOPE_BASE;
			outJson = getOutJson1(statusCode, false, statusCode.toString(), null);
			log.error("获取字典信息失败！",e);
		}
		return outJson;
	}
}
